Skip to content

Create the database directory when it is missing - #6

Merged
tetujin merged 1 commit into
mainfrom
fix/create-database-directory
Nov 18, 2026
Merged

tetujin merged 1 commit into
mainfrom
fix/create-database-directory

Conversation

@tetujin

@tetujin tetujin commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • SQLiteEngine stores databases in the Documents directory. SQLite does not create directories, so when Documents is missing, opening the database fails, getSQLiteInstance() returns nil, and saves, table creation and syncs are skipped with only a log line.
  • Documents always exists in an app, so apps are not affected. It is missing when Swift package tests run on the iOS Simulator without a host app, which made BatterySensor's testTablesAreCreated fail on a fresh simulator.
  • The parent directory of the database file is now created before the DatabaseQueue is opened.

Test plan

  • swift test: 89 tests pass, including the new testCreateParentDirectoryOfDatabase (a database in a missing nested directory can be opened)
  • com.awareframework.ios.sensor.battery tests against this branch on a fresh iOS Simulator (no Documents directory): 10 tests, 0 failures (testTablesAreCreated failed 3 assertions with core 1.6.3)

🤖 Generated with Claude Code

SQLite does not create directories, so opening a database in a missing
directory failed. SQLiteEngine stores databases in the Documents directory,
which exists in an app but not, for example, when Swift package tests run on
the iOS Simulator without a host app. Then getSQLiteInstance() returned nil
and saves, table creation and syncs were skipped with only a log line (this
made BatterySensor's testTablesAreCreated fail on a fresh simulator).

- Create the parent directory before opening the DatabaseQueue.
- Test: a database in a missing nested directory can be opened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tetujin
tetujin merged commit c6ed14e into main Nov 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant